package com.bijava.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author bishichu
 * @since 2021-09-13
 * @description 分页查询条件
 */
@ApiModel(description = "分页对象")
public class PageQuery<V> implements Serializable {
    private static final long serialVersionUID = -2339102992310967358L;

    @ApiModelProperty(value = "当前页码",required = true)
    private Integer pageNo = 1;

    @ApiModelProperty(value = "每页条数",required = true)
    private Integer pageSize = 10;

    @ApiModelProperty(value = "查询条件")
    private V condition;

    @ApiModelProperty(value = "排序条件",hidden = true)
    private Map<String,String> orderMap = new LinkedHashMap<>(8);

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public V getCondition() {
        return condition;
    }

    public void setCondition(V condition) {
        this.condition = condition;
    }

    public Map<String, String> getOrderMap() {
        return orderMap;
    }

    public void setOrderMap(Map<String, String> orderMap) {
        this.orderMap = orderMap;
    }

    /**
     * 修复sonar关于Object、List等类型的序列化问题
     * @param in
     * @throws IOException
     * @throws ClassNotFoundException
     */
    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        in.defaultReadObject();
    }

    /**
     * 修复sonar关于Object、List等类型的序列化问题
     * @param out
     * @throws IOException
     */
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
    }
}